<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增ERP人事报销" bodyClass="white-bg" libs=["prism","bootstrapSelect","ueditor"]/>
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-reimburse-add"  class="form-horizontal">
    <input name="applyUserid" value="${user.id}" class="form-control" type="hidden">
    <input name="serialNumber" value="${serNumber}" class="form-control" type="hidden">
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "申请人"/>：
    </label>
        <div class="col-sm-8"><input name="applyUsername" value="${user.name}" class="form-control" type="text" readonly="true">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "费用发生日期"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="reimburseCostTime"  data-type="date" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "报销金额"/>：
    </label>
        <div class="col-sm-8"><input name="reimburseMoney" class="form-control" type="number"  required>
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "报销凭证"/>：
    </label>
        <div class="col-sm-8">
            <div class="layui-upload">
                <button type="button" class="btn btn-success btn-sm" id="proofList"><i class="fa fa-upload"></i> 上传凭证</button>
                <div class="layui-upload-list layui-upList-minHeight uploadpadding">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>文件名</th>
                            <th>大小</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="demoproofList">
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-btn-Center">
                    <div class="layui-input-block text-right">
                        <button type="button" class="layui-btn layui-btn-xs" id="proofListAction">开始上传</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="reimburseRemark" class="form-control" required></textarea>
        </div>
    </div>
</@form.form>
</div>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "erp/reimburse"
    $("#form-reimburse-add").validate({
        focusCleanup: true
    });

    function submitHandler() {

        if (opt.validate.form()) {
            var fileLength=$("#demoproofList").children().length;
            if(fileLength<=0){
                opt.warning("请上传报销凭证");
                return;
            }
            opt.operate.save(prefix + "/add", $('#form-reimburse-add').serialize());
        }
    }
    //在插件中使用对象
    $.fn.upfile = function(type) {
        var upfile = new Upfile(this,'',$("input[name='serialNumber']").val(),type);
        // var upfile = new Upfile(this,'',"1CC4200F-40D3-4014-B2D7-3465218D550D",type);
        layui.use('upload', function() {
            var upload = layui.upload;
            var UplodeIn = upload.render(upfile.options);
            upfile.SetInst(UplodeIn)

        });

    };
    /**
     * 凭证
     */
    $('#proofList').upfile(4);
</script>
</@footer>
</@pageTheme>